package ninja.awesome.game.gameobject;

import ninja.awesome.framework.Graphics;
import ninja.awesome.game.MainGameScreen;
import ninja.awesome.game.compat.Rectangle;
import ninja.awesome.game.main.Controller;
import ninja.awesome.game.main.Physics;
import ninja.awesome.game.main.Sprites;

public class BossAttack extends EnemyAttack {

	private int damage = 50;
	private int speed = 10;
	private int timer = 0;
	private boolean hit = false;

	// private Image image;

	public BossAttack(int x, int y, int speed, MainGameScreen game, Controller c, Sprites s) {
		super(x, y, speed, game, c, s, "left", 0);
	}

	@Override
	public void update() {
		xLoc -= speed;
		yLoc += speed;

		if (yLoc >= (MainGameScreen.HEIGHT + 10)) {
			c.removeHostile(this);
		}

		if (!hit) {

			if (yLoc >= (MainGameScreen.HEIGHT + 10)) {
				c.removeHostile(this);
			}

			if (Physics.collision(game.getNinja(), this)) {
				hit = true;
				boom.play(1f);
				game.getNinja().setHEALTH(game.getNinja().getHEALTH() - 15);
			}

			anim.runAnimation();
		} else if (hit) {
			if (timer > 40) {
				c.removeHostile(this);
				hit = false;
			}
			// explosion.runAnimation();
			timer++;
		}
		anim.runAnimation();
	}

	@Override
	public void draw(Graphics g) {
		anim.drawAnimation(g, xLoc, yLoc);
	}

	@Override
	public Rectangle getBounds() {
		return new Rectangle(xLoc, yLoc, 16, 16);
	}

	@Override
	public int getX() {
		return this.xLoc;
	}

	@Override
	public int getY() {
		return this.yLoc;
	}

	public int getDamage() {
		return damage;
	}

	public void setDamage(int damage) {
		this.damage = damage;
	}

}